package com.hx.springboot1.dao;

import com.hx.springboot1.pojo.entity.TabCourse;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Author: hx
 * Date: 2021-05-24 14/54
 * Description: Nothing else
 */
@Mapper
@Repository
public interface CourseDao {
    @Select("select * from tab_course")
    List<TabCourse> selectAllCourse();
    @Select("select * from tab_course where course_name like #{courseName}")
    List<TabCourse> selectCourseByName(String courseName);
    @Select("select * from tab_course where course_id = #{courseId}")
    TabCourse selectCourseById(int courseId);
    @Insert("insert into tab_course(course_name,course_score,course_term,course_type,course_testType,course_hour,course_practice)" +
            " values(#{course_name},#{course_score},#{course_term},#{course_type},#{course_testType},#{course_hour},#{course_practice})")
    int insertCourse(String course_name,int course_score,int course_term,String course_type,String course_testType,int course_hour,int course_practice);
    @Update("update tab_course set course_name = #{courseName},course_score = #{score}," +
            " course_term = #{term},course_type = #{courseType},course_testType = #{testType}," +
            " course_hour = #{courseHour},course_practice = #{practiceHour}\n" +
            " where course_id = #{courseId}")
    int updateCourse(int courseId,String courseName,int score,int term,String courseType,String testType,int courseHour,int practiceHour);
    @Delete("delete from tab_course where course_id = #{id}")
    int delCourse(int id);
    @Select("select * from tab_course where course_term = #{termId}")
    List<TabCourse> selectCourseByTermId(int termId);

}
